package com.ruoyi.flink.util.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @Description: 链接 clickHouse
 * @ClassName: ClickHouseLink
 * @author syc
 * @date: 2022年5月26日 下午7:35:10
 */
public class ClickHouseLink {
	private static Connection connection;
	private static String user = "default";
	private static String password = "123456";
	private static String driver = "ru.yandex.clickhouse.ClickHouseDriver";
	private static String host = "192.168.1.125";
	private static String port = "8123";
	private static String database = "default";
	private static String url = "jdbc:clickhouse://" + host + ":" + port + "/" + database;

	public static Connection getConn() throws SQLException, ClassNotFoundException {
		Class.forName(driver);
		connection = DriverManager.getConnection(url, user, password);
		return connection;
	}
	
	public static Connection getConn(String url, String user, String password) throws ClassNotFoundException, SQLException{
		Class.forName(driver);
		connection = DriverManager.getConnection(url, user, password);
		return connection;
	}

}
